#!/bin/sh
set -u

#shellcheck source=../environment.in
. ./environment

rm -rf "${tmp:?}"/*
rm -rf "${logdir:?}"/*.log
rm -rf "${working:?}"/*.bsr "${working:?}"/log*.sd
rm -rf "${working:?}"/*.trace "${working:?}"/*.traceback "${working:?}"/*.bactrace
rm -rf "${working:?}"/*.state
rm -rf "${working:?}"/*.conmsg
rm -rf "${working:?}"/*.pid
rm -rf "${working:?}"/*.mail
rm -rf "${working:?}"/CLEANUPMARKER
rm -rf "${working:?}"/plugins/*
rm -rf "${archivedir:?}"/*
rm -f  "${config_directory_dir_additional_test_config}"/*
rm -f  "${PIDDIR}"/*
find . -name "gigaslam.gif" -exec rm -f {} \;

# cleanup chrome user data (selenium tests)
rm -rf /tmp/chrome-user-data-*

"${rscripts}/susan" stop >/dev/null

${scripts}/drop_susan_tables ${DBTYPE} >/dev/null
${scripts}/drop_susan_database ${DBTYPE} >/dev/null
echo "creating database (${DBTYPE})"
${scripts}/create_susan_database ${DBTYPE} >/dev/null
${scripts}/make_susan_tables ${DBTYPE} >/dev/null
${scripts}/grant_susan_privileges ${DBTYPE} >/dev/null
